var mysql =require('mysql');

var connection = mysql.createConnection({
  host:'localhost',
  user:'root',
  password:'123456',
  database:'library'
});

var sql = "select * from book ";

connection.query(sql,function(err,rows,fields){
  if(err)
    console.log(err);
  else{
    console.log(rows);
  }
  //记得关闭连接
  connection.end();

});
